package com.lzq.leetcode.lanqiao;

import java.time.LocalDate;
import java.util.HashSet;
import java.util.Set;

public class s3492 {

    public static void main(String[] args) {


        int[] arr = new int[]{5,6,8,6,9,1,6,1,2,4,9,1,9,8,2,3,6,4,7,7,5,9,5,0,3,8,7,5,8,1,5,8,6,1,8,3,0,3,7,9,2,7,0,5,8,8,5,7,0,9,9,1,9,4,4,6,8,6,3,3,8,5,1,6,3,4,6,7,0,7,8,2,7,6,8,9,5,6,5,6,1,4,0,1,0,0,9,4,8,0,9,1,2,8,5,0,2,5,3,3};

        int[] dataArr = new int[8];

        int[] counter = new int[]{0};

        Set<LocalDate> ret = new HashSet<>();

        dfs(arr, dataArr, 0, 0, ret);

        System.out.println(ret.size());

    }

    private static void dfs(int[] arr, int[] data, int p, int star, Set<LocalDate> ret) {
        for (int i=star; i<arr.length; i++) {

            data[p] = arr[i];

            if ( (p == 0 && data[p]!=2) || (p == 1 && data[p]!=0) || (p == 2 && data[p]!=2) || (p == 3 && data[p]!=3) ) continue;

            if (p == 4 && data[4] > 1)   continue;
            if (p == 5 && data[4] == 1 && data[5] > 2)   continue;
            if (p == 6 && data[6] > 3)   continue;
            if (p == 7 && data[6] == 3 && data[7] > 1)  continue;


            if (p == 7) {
                // 查看后面的日期是否存在
                int month = data[4] * 10 + data[5];
                int day = data[6] * 10 + data[7];

                // 查看是否存在
                try {
                    LocalDate ld = LocalDate.of(2023, month, day);

                    ret.add(ld);
                } catch (Exception e) {
                    continue;
                }

            } else {
                dfs(arr, data, p+1, i+1, ret);
            }
            // 深入
        }
    }
}
